﻿using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Project.Domain.IRepository
{

    /// <summary>
    /// 泛型仓储，写入CRUD通用方法
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface IRepository<TEntity> where TEntity : class, new()//IRepository<TEntity> : IDisposable where TEntity : class
    {
       
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="obj"></param>
        Task AddAsync(TEntity obj);
        /// <summary>
        /// 根据Filter获取对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<IAsyncCursor<TEntity>> GetByFilterAsync(FilterDefinition<TEntity> filter);

        /// <summary>
        /// 根据对象进行更新
        /// </summary>
        /// <param name="obj"></param>
        Task<UpdateResult> UpdateAsync(TEntity doc, FilterDefinition<TEntity> filter, UpdateDefinition<TEntity> updateFields);
        /// <summary>
        /// 根据条件删除，可多个删除
        /// </summary>
        /// <param name="filter">删除条件</param>
        Task<DeleteResult> DeleteAsync(FilterDefinition<TEntity> filter);

    }
}
